package control_flow

func Demo1() {
	var a = 10
	println(a)

	var b = (a + a) * a
	println(b)

	// 变为汇编思想
	//var a, b int
	//
	//a = 10
	//runtime.printint(a)
	//runtime.printnl()
	//
	//b = a
	//b += b
	//b *= a
	//runtime.printint(b)
	//runtime.printnl()

}

func If(ok int, a, b int) int {
	// 变为汇编思想
	if ok == 0 {
		goto L
	}
	return a
L:
	return b
}

func LoopAdd(cnt, v0, step int) int {
	var i = 0
	var result = 0

	result = v0

LOOP_IF:
	if i < cnt {
		goto LOOP_BODY
	}
	goto LOOP_END

LOOP_BODY:
	i = i + 1
	result = result + step
	goto LOOP_IF

LOOP_END:

	return result
}
